package utils;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;



public class InjectionType extends JDialog implements ActionListener
	{
	/************
	 * Variables
	 ***********/
	boolean choice;
	
	
	//Panel
	JPanel firstChoice;
	JPanel secondChoice;
	JPanel global;
	
	//Controle
	JButton firstButton;
	JButton secondButton;
	
	/*****************
	 * Constructeurs
	 *****************/
	public InjectionType(JFrame maFenetre)
		{
		super(maFenetre,"Choose injection method",true);
		choice = true;
		
		
		//Controle
		firstButton = new JButton("File generation");
		secondButton = new JButton("AXL injection");
		
		//Panel
		firstChoice = new JPanel();
		secondChoice = new JPanel();
		global = new JPanel();
		
		//Disposition
		firstChoice.setLayout(new BoxLayout(firstChoice, BoxLayout.X_AXIS));
		secondChoice.setLayout(new BoxLayout(secondChoice, BoxLayout.X_AXIS));
		global.setLayout(new BoxLayout(global, BoxLayout.Y_AXIS));
		
		//Association
		firstChoice.add(new JLabel("Pour utiliser le fichier de collecte CollecteMaster Cliquez ici >>"));
		firstChoice.add(Box.createHorizontalGlue());
		firstChoice.add(firstButton);
		secondChoice.add(new JLabel("Pour utiliser le fichier de collecte client Cliquez ici >>"));
		secondChoice.add(Box.createHorizontalGlue());
		secondChoice.add(secondButton);
		global.add(firstChoice);
		global.add(secondChoice);
		this.add(global);
		
		//Event
		firstButton.addActionListener(this);
		secondButton.addActionListener(this);
		
		this.pack();
		new Centrer(this);
		this.setVisible(true);
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		}
	
	
	
	
	
	public boolean getChoice()
		{
		/**************************************************************
		 * If choice is true, normal CollecteMaster file will be used
		 * otherwise the customer's file.
		 **************************************************************/
		return choice;
		}

	public void actionPerformed(ActionEvent evt)
		{
		if(evt.getSource() == this.firstButton)
			{
			choice = true;
			this.setVisible(false);
			}
		if(evt.getSource() == this.secondButton)
			{
			choice = false;
			this.setVisible(false);
			}
		}
	
	/*2010*//*AR ;)*/
	}
